package cn.xiuxius.embedded.toolwindow.model;

import lombok.experimental.Accessors;

import java.util.List;
import java.util.function.Supplier;

@Accessors(chain = true)
public class BooleanCommandOption extends AbstractCommandOption<Boolean> {

    public BooleanCommandOption(String cmdFlag, boolean defaultValue, boolean onlyFlag) {
        super(cmdFlag, Boolean.toString(defaultValue), onlyFlag);
        setOptions(List.of("true", "false"));
    }

    @Override
    public AbstractCommandOption<Boolean> options(Supplier<List<Boolean>> provider) {
        super.setOptions(provider.get().stream().map(String::valueOf).toList());
        return this;
    }

    @Override
    public boolean isValid() {
        return super.getOptions().contains(getCmdValue());
    }

}
